home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
shutdown-fx-20-c
/
sfx control app ƒ
/
Shell ƒ
/
help.c
< prev
next >
Wrap
Text File
|
1994-07-11
|
22KB
|
830 lines
/**********************************************************************\
File: help.c
Purpose: This module handles displaying the different help windows.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program in a file named "GNU General Public License".
If not, write to the Free Software Foundation, 675 Mass Ave,
Cambridge, MA 02139, USA.
\**********************************************************************/
#include "help.h"
#include "environment.h"
#include "util.h"
#include "buttons.h"
#include "timing.h"
#include "program globals.h"
#define DEAD_SPACE_TOP 10
#define DEAD_SPACE_LEFT 10
#define DEAD_SPACE_BOTTOM 27
#define DEAD_SPACE_RIGHT 10
#define TEXT_RECT_WIDTH 405
#define TEXT_RECT_HEIGHT 250
#define BUTTON_WIDTH 60
#define BUTTON_HEIGHT 60
#define XREF_DEAD_SPACE_TOP 5
#define XREF_TEXT_WIDTH 46
#define XREF_WIDTH 70
#define XREF_HEIGHT 17
#define XREF_GAP 5
#define MAX_MAIN_TOPICS 4
#define MAX_SUB_TOPICS 5
#define MAX_XREFS 4
#define MAIN_TOPIC_ID 600
#define FIRST_SUB_TOPIC_ID 610
#define theWindowWidth (boundsRect.right-boundsRect.left)
#define theWindowHeight (boundsRect.bottom-boundsRect.top)
#define CorrectTime 1
#define SCROLL_BOX_SIZE 20
typedef unsigned char **CharHandle;
typedef struct
{
long offset;
short lineHeight;
short fontDescent;
short fontNum;
unsigned char fontStyle;
unsigned char unused1;
short fontSize;
short unused2;
short unused3;
short unused4;
} OneStyle;
typedef struct
{
short numStyles;
OneStyle theStyle[31];
} StylRec, *StylPtr, **StylHandle;
enum
{
kLeft=0,
kCenter
};
short gNumMainTopics;
short gNumSubTopics[MAX_MAIN_TOPICS];
short gNumXRefs[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
CIconHandle gMainTopicIconColor[MAX_MAIN_TOPICS];
Handle gMainTopicIconBW[MAX_MAIN_TOPICS];
Str31 gMainTopicTitle[MAX_MAIN_TOPICS];
Rect gMainTopicRect[MAX_MAIN_TOPICS];
CIconHandle gSubTopicIconColor[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
Handle gSubTopicIconBW[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
Str31 gSubTopicTitle[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
Rect gSubTopicRect[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
short gSubTopicID[MAX_MAIN_TOPICS][MAX_SUB_TOPICS];
short gXRefIndex[MAX_MAIN_TOPICS][MAX_SUB_TOPICS][MAX_XREFS];
Rect gXRefRect[MAX_XREFS];
short gStickyTopic;
short gStickySubTopic;
short gMainTopicShowing; /* saved in prefs file */
short gSubTopicShowing; /* saved in prefs file */
Rect gTextRect;
CharHandle gTheText;
StylHandle gTheStyle;
/*-----------------------------------------------------------------------------------*/
/* internal stuff for help.c */
void SetupTheHelpWindow(WindowDataHandle theData);
void ShutdownTheHelpWindow(WindowDataHandle theData);
void InitializeTheHelpWindow(WindowDataHandle theData);
void OpenTheHelpWindow(WindowDataHandle theData);
void KeyPressedInHelpWindow(WindowDataHandle theData, unsigned char keyPressed);
void MouseClickedInHelpWindow(WindowDataHandle theData, Point mouseLoc);
void DrawTheHelpWindow(short theDepth);
void DrawTheText(CharHandle theText, StylHandle theStyleHandle, short theJust,
short theMode, Rect theRect);
void DrawTheShadowBox(Rect theRect);
short ParseRawTitle(Str255 theTitle, short *xRef, short *numXRefs);
void GoToPage(WindowDataHandle theData, short mainTopic, short subTopic,
Boolean updateNow);
void PushInSubTopic(WindowDataHandle theData);
void PullOutSubTopic(WindowDataHandle theData, short mainTopic);
void HighlightSubTopic(WindowDataHandle theData, short mainTopic, short subTopic,
Boolean isHighlighted);
void GetTextResources(short mainTopic, short subTopic);
void DisposeTextResources(void);
void FullScrollRight(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
void CalculateXRefInfo(short index, short *mainTopic, short *subTopic, Str255 name);
short HelpWindowDispatch(WindowDataHandle theData, short theMessage, unsigned long misc)
{
unsigned char theChar;
Point thePoint;
short theDepth;
switch (theMessage)
{
case kUpdate:
theDepth=misc&0x7fff;
DrawTheHelpWindow(theDepth);
return kSuccess;
break;
case kKeydown:
theChar=misc&charCodeMask;
KeyPressedInHelpWindow(theData, theChar);
return kSuccess;
break;
case kMousedown:
thePoint.h=(misc>>16)&0x7fff;
thePoint.v=misc&0x7fff;
MouseClickedInHelpWindow(theData, thePoint);
return kSuccess;
break;
case kOpen:
OpenTheHelpWindow(theData);
return kSuccess;
break;
case kInitialize:
InitializeTheHelpWindow(theData);
return kSuccess;
break;
case kStartup:
SetupTheHelpWindow(theData);
return kSuccess;
break;
case kShutdown:
ShutdownTheHelpWindow(theData);
return kSuccess;
break;
}
return kFailure; /* revert to default processing for all other messages */
}
void SetupTheHelpWindow(WindowDataHandle theData)
{
short i,j;
unsigned char *helpStr="\pHelp";
Handle temp;
short iconID;
short centeringOffset;
temp=GetResource('STR#', MAIN_TOPIC_ID);
gNumMainTopics=**((short**)temp);
ReleaseResource(temp);
for (i=0; i<gNumMainTopics; i++)
{
temp=GetResource('STR#', FIRST_SUB_TOPIC_ID+i);
gNumSubTopics[i]=**((short**)temp);
ReleaseResource(temp);
}
centeringOffset=DEAD_SPACE_TOP;
for (i=0; i<gNumMainTopics; i++)
{
GetIndString(gMainTopicTitle[i], MAIN_TOPIC_ID, i+1);
iconID=ParseRawTitle(gMainTopicTitle[i], 0L, 0L);
if (gHasColorQD)
{
gMainTopicIconColor[i]=0L;
gMainTopicIconColor[i]=GetCIcon(iconID);
}
gMainTopicIconBW[i]=0L;
gMainTopicIconBW[i]=GetIcon(iconID);
SetRect(&gMainTopicRect[i], DEAD_SPACE_LEFT, centeringOffset+BUTTON_HEIGHT*i,
DEAD_SPACE_LEFT+BUTTON_WIDTH, centeringOffset+BUTTON_HEIGHT*(i+1));
for (j=0; j<gNumSubTopics[i]; j++)
{
GetIndString(gSubTopicTitle[i][j], FIRST_SUB_TOPIC_ID+i, j+1);
iconID=ParseRawTitle(gSubTopicTitle[i][j], gXRefIndex[i][j], &(gNumXRefs[i][j]));
gSubTopicID[i][j]=iconID;
if (gHasColorQD)
{
gSubTopicIconColor[i][j]=0L;
gSubTopicIconColor[i][j]=GetCIcon(iconID);
}
gSubTopicIconBW[i][j]=0L;
gSubTopicIconBW[i][j]=GetIcon(iconID);
SetRect(&gSubTopicRect[i][j], DEAD_SPACE_LEFT+BUTTON_WIDTH*(j+1),
centeringOffset+BUTTON_HEIGHT*i, DEAD_SPACE_LEFT+BUTTON_WIDTH*(j+2),
centeringOffset+BUTTON_HEIGHT*(i+1));
}
}
for (i=0; i<MAX_XREFS; i++)
{
SetRect(&gXRefRect[i], XREF_TEXT_WIDTH+DEAD_SPACE_LEFT+BUTTON_WIDTH+DEAD_SPACE_LEFT+
i*(XREF_WIDTH+XREF_GAP), DEAD_SPACE_TOP+TEXT_RECT_HEIGHT+XREF_DEAD_SPACE_TOP,
XREF_TEXT_WIDTH+DEAD_SPACE_LEFT+BUTTON_WIDTH+DEAD_SPACE_LEFT+
i*(XREF_WIDTH+XREF_GAP)+XREF_WIDTH, DEAD_SPACE_TOP+TEXT_RECT_HEIGHT+
XREF_DEAD_SPACE_TOP+XREF_HEIGHT);
}
gTheText=gTheStyle=0L;
GoToPage(0L, gMainTopicShowing, gSubTopicShowing, FALSE);
SetRect(&gTextRect, DEAD_SPACE_LEFT+BUTTON_WIDTH+DEAD_SPACE_LEFT, DEAD_SPACE_TOP,
DEAD_SPACE_LEFT+BUTTON_WIDTH+DEAD_SPACE_LEFT+TEXT_RECT_WIDTH,
DEAD_SPACE_TOP+TEXT_RECT_HEIGHT);
(**theData).maxDepth=8;
(**theData).windowWidth=DEAD_SPACE_LEFT+BUTTON_WIDTH+DEAD_SPACE_LEFT+
TEXT_RECT_WIDTH+DEAD_SPACE_RIGHT;
(**theData).windowHeight=DEAD_SPACE_TOP+TEXT_RECT_HEIGHT+DEAD_SPACE_BOTTOM;
(**theData).windowType=noGrowDocProc; /* document-looking thing */
(**theData).hasCloseBox=TRUE;
(**theData).windowBounds.top=50;
(**theData).windowBounds.left=6;
SetIndWindowTitle(kHelp, helpStr);
}
void ShutdownTheHelpWindow(WindowDataHandle theData)
{
short i,j;
for (i=0; i<gNumMainTopics; i++)
{
if (gHasColorQD)
if (gMainTopicIconColor[i]!=0L)
DisposeCIcon(gMainTopicIconColor[i]);
if (gMainTopicIconBW[i]!=0L)
ReleaseResource(gMainTopicIconBW[i]);
for (j=0; j<gNumSubTopics[i]; j++)
{
if (gHasColorQD)
if (gSubTopicIconColor[i][j]!=0L)
DisposeCIcon(gSubTopicIconColor[i][j]);
if (gSubTopicIconColor[i][j]!=0L)
ReleaseResource(gSubTopicIconColor[i][j]);
}
}
DisposeTextResources();
}
void InitializeTheHelpWindow(WindowDataHandle theData)
{
(**theData).initialTopLeft.v=(**theData).windowBounds.top-9;
(**theData).initialTopLeft.h=(**theData).windowBounds.left;
gStickyTopic=-1;
}
void OpenTheHelpWindow(WindowDataHandle theData)
{
(**theData).offscreenNeedsUpdate=TRUE;
}
void KeyPressedInHelpWindow(WindowDataHandle theData, unsigned char keyPressed)
{
short oldTopic;
ObscureCursor();
switch (keyPressed)
{
case 0x1d: /* right arrow */
if (gStickyTopic==-1)
{
gSubTopicShowing++;
if (gSubTopicShowing>=gNumSubTopics[gMainTopicShowing])
{
gSubTopicShowing=0;
gMainTopicShowing++;
if (gMainTopicShowing>=gNumMainTopics)
gMainTopicShowing=0;
}
GoToPage(theData, gMainTopicShowing, gSubTopicShowing, TRUE);
}
else
{
if (gStickySubTopic!=-1)
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, FALSE);
gStickySubTopic++;
if (gStickySubTopic>=gNumSubTopics[gStickyTopic])
gStickySubTopic=0;
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, TRUE);
}
break;
case 0x1c: /* left arrow */
if (gStickyTopic==-1)
{
gSubTopicShowing--;
if (gSubTopicShowing<0)
{
gMainTopicShowing--;
if (gMainTopicShowing<0)
gMainTopicShowing=gNumMainTopics-1;
gSubTopicShowing=gNumSubTopics[gMainTopicShowing]-1;
}
GoToPage(theData, gMainTopicShowing, gSubTopicShowing, TRUE);
}
else
{
if (gStickySubTopic!=-1)
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, FALSE);
gStickySubTopic--;
if (gStickySubTopic<0)
gStickySubTopic=gNumSubTopics[gStickyTopic]-1;
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, TRUE);
}
break;
case 0x1e: /* up arrow */
if (gStickyTopic!=-1)
{
oldTopic=gStickyTopic;
PushInSubTopic(theData);
gStickyTopic=oldTopic-1;
if (gStickyTopic<0)
gStickyTopic=gNumMainTopics-1;
}
else gStickyTopic=gNumMainTopics-1;
PullOutSubTopic(theData, gStickyTopic);
break;
case 0x1f: /* down arrow */
if (gStickyTopic!=-1)
{
oldTopic=gStickyTopic;
PushInSubTopic(theData);
gStickyTopic=oldTopic+1;
if (gStickyTopic>=gNumMainTopics)
gStickyTopic=0;
}
else gStickyTopic=0;
PullOutSubTopic(theData, gStickyTopic);
break;
case 0x1b: /* escape key */
if (gStickyTopic!=-1)
PushInSubTopic(theData);
else CloseTheWindow(theData);
break;
case 0x03:
case 0x0d:
if (gStickyTopic==-1)
{
gStickyTopic=gMainTopicShowing;
PullOutSubTopic(theData, gStickyTopic);
}
else
{
if (gStickySubTopic!=-1)
{
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, FALSE);
GoToPage(theData, gStickyTopic, gStickySubTopic, TRUE);
}
else PushInSubTopic(theData);
}
break;
}
}
void MouseClickedInHelpWindow(WindowDataHandle theData, Point mouseLoc)
{
short newTopic;
Boolean isColor;
short i;
Str255 name;
short newMain, newSub;
isColor=((**theData).windowDepth>2);
newTopic=-1;
for (i=0; i<gNumXRefs[gMainTopicShowing][gSubTopicShowing]; i++)
{
if (PtInRect(mouseLoc, &gXRefRect[i]))
{
CalculateXRefInfo(gXRefIndex[gMainTopicShowing][gSubTopicShowing][i],
&newMain, &newSub, name);
if ((newMain!=-1) && (newSub!=-1))
{
if (Track3DButton(&gXRefRect[i], name, 0L, (**theData).windowDepth))
{
GoToPage(theData, newMain, newSub, TRUE);
return;
}
}
}
}
for (i=0; i<gNumMainTopics; i++)
{
if (PtInRect(mouseLoc, &gMainTopicRect[i]))
{
newTopic=i;
i=gNumMainTopics;
}
}
if (newTopic!=-1)
{
if (newTopic==gStickyTopic)
PushInSubTopic(theData);
else
{
if (gStickyTopic!=-1)
PushInSubTopic(theData);
PullOutSubTopic(theData, newTopic);
gStickyTopic=newTopic;
}
}
if ((gStickyTopic!=-1) && (newTopic==-1))
{
for (i=0; i<gNumSubTopics[gStickyTopic]; i++)
{
if (PtInRect(mouseLoc, &gSubTopicRect[gStickyTopic][i]))
{
if (gStickySubTopic!=-1)
HighlightSubTopic(theData, gStickyTopic, gStickySubTopic, FALSE);
gStickySubTopic=-1;
if (Track3DButton(&gSubTopicRect[gStickyTopic][i],
gSubTopicTitle[gStickyTopic][i], isColor ?
(Handle)gSubTopicIconColor[gStickyTopic][i] :
gSubTopicIconBW[gStickyTopic][i], (**theData).windowDepth))
{
newTopic=i;
i=gNumSubTopics[gStickyTopic];
}
}
}
if (newTopic!=-1)
GoToPage(theData, gStickyTopic, newTopic, TRUE);
else
PushInSubTopic(theData);
}
}
void DrawTheHelpWindow(short theDepth)
{
GrafPtr curPort;
short i,j;
Boolean isColor;
Rect tempRect;
Str255 theStr;
short dummy1, dummy2;
isColor=(theDepth>2);
GetPort(&curPort);
EraseRect(&(curPort->portRect));
DrawTheShadowBox(gTextRect);
if (gTheText!=0L)
{
tempRect=gTextRect;
InsetRect(&tempRect, 8, 4);
DrawTheText(gTheText, gTheStyle, kLeft, srcOr, tempRect);
}
for (i=0; i<gNumMainTopics; i++)
{
Draw3DButton(&gMainTopicRect[i], gMainTopicTitle[i],
isColor ? (Handle)gMainTopicIconColor[i] : gMainTopicIconBW[i],
theDepth, (i==gStickyTopic));
if (i==gStickyTopic)
{
for (j=0; j<gNumSubTopics[i]; j++)
{
Draw3DButton(&gSubTopicRect[i][j], gSubTopicTitle[i][j],
isColor ? (Handle)gSubTopicIconColor[i][j] : gSubTopicIconBW[i][j],
theDepth, (j==gStickySubTopic));
}
}
}
for (i=0; i<gNumXRefs[gMainTopicShowing][gSubTopicShowing]; i++)
{
CalculateXRefInfo(gXRefIndex[gMainTopicShowing][gSubTopicShowing][i],
&dummy1, &dummy2, theStr);
Draw3DButton(&gXRefRect[i], theStr, 0L, theDepth, FALSE);
}
if (gNumXRefs[gMainTopicShowing][gSubTopicShowing]>0)
{
MoveTo(gXRefRect[0].left-XREF_TEXT_WIDTH, gXRefRect[0].bottom-5);
TextFont(geneva);
TextSize(9);
DrawString("\pSee also:");
}
}
void DrawTheText(CharHandle theText, StylHandle theStyleHandle, short theJust,
short theMode, Rect theRect)
{
short i, numStyles;
long textPos;
long maxOffset;
Str255 thisLine;
Boolean notDoneYet;
unsigned char thisChar;
short theRow, theCol;
unsigned char lastEnd, thisEnd;
Boolean overRun;
numStyles=(**theStyleHandle).numStyles;
textPos=0L;
theRow=theRect.top+(**theStyleHandle).theStyle[0].fontDescent+1;
theCol=theRect.left;
thisLine[0]=0x00;
lastEnd=0;
for (i=0; i<numStyles; i++)
{
if (i==numStyles-1)
maxOffset=GetHandleSize(theText);
else
maxOffset=(**theStyleHandle).theStyle[i+1].offset;
TextFont((**theStyleHandle).theStyle[i].fontNum);
TextFace((**theStyleHandle).theStyle[i].fontStyle);
TextSize((**theStyleHandle).theStyle[i].fontSize);
TextMode(theMode);
while (textPos<maxOffset)
{
notDoneYet=TRUE;
while ((textPos<maxOffset) && (notDoneYet))
{
thisChar=thisLine[++thisLine[0]]=(*theText)[textPos++];
notDoneYet=((thisChar!=' ') && (thisChar!=0x0d));
}
thisEnd=thisLine[0];
overRun=(theRect.right-theCol<=StringWidth(thisLine));
if ((overRun) || (thisChar==0x0d) || (textPos==maxOffset))
{
if (overRun)
thisLine[0]=lastEnd;
if (theJust==kCenter)
MoveTo((theRect.right-theRect.left-StringWidth(thisLine))/2+
theCol, theRow);
else
MoveTo(theCol, theRow);
theCol+=StringWidth(thisLine);
DrawString(thisLine);
if (overRun)
{
BlockMove(&thisLine[lastEnd+1], &thisLine[1], thisEnd-lastEnd+1);
if (thisEnd>=lastEnd)
{
thisLine[0]=thisEnd-lastEnd-1;
textPos--;
}
else
thisEnd=thisLine[0]=0x00;
}
else thisLine[0]=0x00;
if ((overRun) || (thisChar==0x0d))
{
theRow+=(**theStyleHandle).theStyle[i].lineHeight;
theCol=theRect.left;
}
}
lastEnd=thisEnd;
}
if (thisLine[0]!=0x00)
{
if (theJust==kCenter)
MoveTo((theRect.right-theRect.left-StringWidth(thisLine))/2+
theCol, theRow);
else
MoveTo(theCol, theRow);
theCol+=StringWidth(thisLine);
DrawString(thisLine);
thisLine[0]=0x00;
}
}
TextMode(srcOr);
}
void DrawTheShadowBox(Rect theRect)
{
theRect.right-=2;
theRect.bottom-=2;
FrameRect(&theRect);
MoveTo(theRect.left+3, theRect.bottom+1);
Line(theRect.right-theRect.left-2, 0);
Line(0, -theRect.bottom+theRect.top+3);
MoveTo(theRect.left+3, theRect.bottom);
Line(theRect.right-theRect.left-3, 0);
Line(0, -theRect.bottom+theRect.top+4);
}
short ParseRawTitle(Str255 theTitle, short *xRef, short *numXRefs)
{
Str255 numStr;
unsigned long result;
short i,j;
Boolean gotbullet;
Boolean moreXRefs;
if (xRef!=0L)
{
*numXRefs=0;
for (j=1, gotbullet=FALSE; ((j<=theTitle[0]) && (!gotbullet)); j++)
gotbullet=(theTitle[j]=='%');
if (gotbullet)
{
i=j;
do
{
numStr[0]=0x00;
while ((numStr[0]<=theTitle[0]-i) &&
(((numStr[numStr[0]]=theTitle[i+(numStr[0]++)]))!=' ')) {}
if (numStr[numStr[0]]==' ')
{
moreXRefs=TRUE;
i+=numStr[0];
numStr[0]--;
}
else moreXRefs=FALSE;
StringToNum(numStr, &result);
xRef[(*numXRefs)++]=result;
}
while (moreXRefs);
theTitle[0]=j-2;
}
}
numStr[0]=0x00;
while ((numStr[numStr[0]]=theTitle[++numStr[0]])!=' ') {}
theTitle[0]-=numStr[0];
Mymemcpy(&theTitle[1], &theTitle[numStr[0]+1], theTitle[0]);
numStr[0]--;
StringToNum(numStr, &result);
return result;
}
void GoToPage(WindowDataHandle theData, short mainTopic, short subTopic,
Boolean updateNow)
{
DisposeTextResources();
GetTextResources(mainTopic, subTopic);
gMainTopicShowing=mainTopic;
gSubTopicShowing=subTopic;
gStickyTopic=gStickySubTopic=-1;
if (updateNow)
{
(**theData).offscreenNeedsUpdate=TRUE;
UpdateTheWindow(theData);
}
}
void PushInSubTopic(WindowDataHandle theData)
{
gStickyTopic=-1;
(**theData).offscreenNeedsUpdate=TRUE;
UpdateTheWindow(theData);
}
void PullOutSubTopic(WindowDataHandle theData, short mainTopic)
{
short i;
short theDepth;
Boolean isColor;
Rect tempRect;
gStickySubTopic=-1;
isColor=(theDepth=(**theData).windowDepth)>2;
SetPortToOffscreen(theData);
for (i=0; i<gNumSubTopics[mainTopic]; i++)
{
Draw3DButton(&gSubTopicRect[mainTopic][i], gSubTopicTitle[mainTopic][i],
isColor ? (Handle)gSubTopicIconColor[mainTopic][i] :
gSubTopicIconBW[mainTopic][i], theDepth, FALSE);
}
RestorePortToScreen(theData);
Draw3DButton(&gMainTopicRect[mainTopic], gMainTopicTitle[mainTopic],
isColor ? (Handle)gMainTopicIconColor[mainTopic] :
gMainTopicIconBW[mainTopic], theDepth, TRUE);
tempRect=gSubTopicRect[mainTopic][0];
tempRect.right=gSubTopicRect[mainTopic][gNumSubTopics[mainTopic]-1].right;
FullScrollRight(GetOffscreenGrafPtr(theData), GetWindowGrafPtr(theData), tempRect);
(**theData).offscreenNeedsUpdate=TRUE;
}
void HighlightSubTopic(WindowDataHandle theData, short mainTopic, short subTopic,
Boolean isHighlighted)
{
Draw3DButton(&gSubTopicRect[mainTopic][subTopic], gSubTopicTitle[mainTopic][subTopic],
((**theData).windowDepth>2) ? (Handle)gSubTopicIconColor[mainTopic][subTopic] :
gSubTopicIconBW[mainTopic][subTopic], (**theData).windowDepth, isHighlighted);
(**theData).offscreenNeedsUpdate=TRUE;
}
void GetTextResources(short mainTopic, short subTopic)
{
short resID;
DisposeTextResources();
resID=gSubTopicID[mainTopic][subTopic];
gTheText=GetResource('TEXT', resID);
gTheStyle=GetResource('styl', resID);
}
void DisposeTextResources(void)
{
if (gTheText!=0L)
ReleaseResource(gTheText);
if (gTheStyle!=0L)
ReleaseResource(gTheStyle);
gTheText=gTheStyle=0L;
}
void FullScrollRight(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
{
Rect sourceRect, destRect, scrollRect;
short BoxSize;
StartTiming();
BoxSize=SCROLL_BOX_SIZE;
destRect=sourceRect=scrollRect=boundsRect;
destRect.right=destRect.left+BoxSize;
sourceRect.left=boundsRect.right-BoxSize;
scrollRect.right=scrollRect.left+2*BoxSize;
CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
&sourceRect, &destRect, 0, 0L);
TimeCorrection(CorrectTime);
while (scrollRect.right<=boundsRect.right)
{
StartTiming();
sourceRect.right-=BoxSize;
sourceRect.left-=BoxSize;
ScrollTheRect(&scrollRect, BoxSize, 0, 0L);
CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
&sourceRect, &destRect, 0, 0L);
TimeCorrection(CorrectTime);
scrollRect.right+=BoxSize;
}
if (scrollRect.right!=boundsRect.right)
CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
&boundsRect, &boundsRect, 0, 0L);
}
void CalculateXRefInfo(short index, short *mainTopic, short *subTopic, Str255 name)
{
short theMain, theSub;
unsigned char *bad="\pBad XRef!";
theMain=gNumMainTopics-1;
theSub=gNumSubTopics[theMain]-1;
while ((theMain>=0) && (index!=gSubTopicID[theMain][theSub]))
{
theSub--;
if (theSub<0)
{
theMain--;
theSub=gNumSubTopics[theMain];
}
}
if (theMain<0)
{
Mymemcpy(name, bad, bad[0]+1);
*mainTopic=*subTopic=-1;
}
else
{
Mymemcpy(name, gSubTopicTitle[theMain][theSub],
gSubTopicTitle[theMain][theSub][0]+1);
*mainTopic=theMain;
*subTopic=theSub;
}
}